package com.mark.spring.annotation.life.cycle.postconstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;

import javax.annotation.PostConstruct;

/**
 * @Description: PostConstruct引导类
 * @Author: Mark
 * @CreateDate: 2019/9/17 21:14
 * @Version: 3.00.001
 * @Copyright : 豆浆油条个人非正式工作室
 *
 * @see PostConstruct
 * @see org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor#postProcessBeforeInitialization 执行@PostConstruct注解标注方法的后置处理器
 *
 * 总结： 对象创建并赋值后调用
 */
@ComponentScan(basePackages = {"com.mark.spring.annotation.life.cycle.postconstruct"})
public class PostConstructBootstrap {

    @Autowired
    private Singer singer;

    public static void main(String[] args) {
        //加载配置，获取bean
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(PostConstructBootstrap.class);

        /*
         * Singer constructor
         * Jay发不了新歌 《说好不哭》
         *
         * 结果表明先执行构造方法 后执行@PostConstruct标注的方法
         */

        //关闭上下文
        applicationContext.close();
    }
}
